package com.SunSoft.PhoneRemoteControl;

import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import java.util.Timer;

final class ei
  implements View.OnTouchListener
{
  public final boolean onTouch(View paramView, MotionEvent paramMotionEvent)
  {
    Object localObject = this.a.getResources().getResourceName(paramView.getId());
    int i = Integer.parseInt(((String)localObject).substring(((String)localObject).length() - 3));
    String str = (String)paramView.getTag();
    localObject = str;
    if (str == null)
      localObject = "0";
    int j = Integer.valueOf((String)localObject).intValue();
    localObject = (Button)paramView;
    switch (paramMotionEvent.getAction())
    {
    default:
      return true;
    case 0:
      Show_Control.a("Test", "ACTION_DOWN" + i);
      if (!(this.a.E))
      {
        this.a.g = i;
        if (Show_Control.g(this.a) != 5)
        {
          this.a.h = this.a.Q[this.a.g];
          if ((this.a.h == null) || (this.a.h.equals("")))
          {
            Toast.makeText(this.a, this.a.getString(2131099751), 0).show();
            return false;
          }
          if (this.a.V[i] != 0)
          {
            this.a.aC = 6;
            new Thread(Show_Control.m(this.a)).start();
            this.a.E = true;
            Show_Control.a("Test", "is_doing=true");
            switch (j)
            {
            default:
              paramMotionEvent = paramView.getBackground();
              paramMotionEvent.setColorFilter(new ColorMatrixColorFilter(Show_Control.a));
              paramView.setBackgroundDrawable(paramMotionEvent);
              ((Button)localObject).setTextColor(Color.rgb(110, 39, 40));
              this.a.r.setImageDrawable(this.a.d);
              Show_Control.a(this.a, 0);
            case 1:
            case 2:
            case 3:
            case 4:
            }
          }
        }
      }
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    this.a.M = false;
                    return false;
                    this.a.aC = 1;
                    new Thread(Show_Control.m(this.a)).start();
                  }
                  Show_Control.a("Test", "power_method:" + this.a.ao);
                  if ((this.a.g == 1) || (this.a.ap != 0) || (this.a.ao == 32))
                    break;
                  Toast.makeText(this.a, this.a.getString(2131099752), 0).show();
                }
                this.a.E = true;
                try
                {
                  paramMotionEvent = this.a;
                  Show_Control.i(this.a);
                  paramMotionEvent.av = di.a(this.a.ag, this.a.g, this.a.au);
                  if ((this.a.av != null) && (this.a.av.length == 7))
                  {
                    this.a.h = this.a.av[0];
                    this.a.ap = Integer.valueOf(this.a.av[1]).intValue();
                    this.a.aq = Integer.valueOf(this.a.av[2]).intValue();
                    this.a.ar = Integer.valueOf(this.a.av[3]).intValue();
                    this.a.as = Integer.valueOf(this.a.av[4]).intValue();
                    this.a.at = Integer.valueOf(this.a.av[5]).intValue();
                    this.a.a();
                    paramMotionEvent = new StringBuilder(String.valueOf(new StringBuilder(String.valueOf(new StringBuilder(String.valueOf(new StringBuilder(String.valueOf("")).append(String.valueOf(this.a.ap)).append("|").toString())).append(String.valueOf(this.a.aq)).append("|").toString())).append(String.valueOf(this.a.ar)).append("|").toString())).append(String.valueOf(new StringBuilder(String.valueOf(this.a.as)).append("|").toString())).toString() + String.valueOf(this.a.at);
                    this.a.au[0] = this.a.ap;
                    this.a.au[1] = this.a.aq;
                    this.a.au[2] = this.a.ar;
                    this.a.au[3] = this.a.as;
                    this.a.au[4] = this.a.at;
                    if (this.a.u != 3)
                      Show_Control.n(this.a).execSQL("update control_list set note = ?  where ID= ? ", new String[] { paramMotionEvent, String.valueOf(Show_Control.o(this.a)) });
                  }
                  this.a.aC = 1;
                  new Thread(Show_Control.m(this.a)).start();
                }
                catch (java.lang.ArrayIndexOutOfBoundsException paramMotionEvent)
                {
                  while (true)
                    this.a.av = null;
                }
                catch (java.lang.ArrayStoreException paramMotionEvent)
                {
                  while (true)
                  {
                    while (true)
                      this.a.av = null;
                    paramView.setBackgroundResource(2130837510);
                  }
                }
              }
              paramView.setBackgroundResource(2130837514);
            }
            paramView.setBackgroundResource(2130837614);
          }
          paramView.setBackgroundResource(2130837607);
        }
        paramView = this.a;
        Show_Control.a(paramView, Show_Control.p(paramView) + 1);
        if (Show_Control.p(this.a) <= 5)
          continue;
        this.a.E = false;
      }
    case 1:
      Show_Control.a("Test", "ACTION_UP" + i);
      switch (j)
      {
      default:
        paramMotionEvent = paramView.getBackground();
        paramMotionEvent.setColorFilter(new ColorMatrixColorFilter(Show_Control.b));
        paramView.setBackgroundDrawable(paramMotionEvent);
      case 1:
      case 2:
      case 3:
      case 4:
      }
      while (true)
      {
        this.a.g = i;
        ((Button)localObject).setTextColor(-1);
        this.a.r.setImageDrawable(this.a.e);
        this.a.M = false;
        return false;
        paramView.setBackgroundResource(2130837506);
        continue;
        paramView.setBackgroundResource(2130837508);
        continue;
        paramView.setBackgroundResource(2130837552);
        continue;
        paramView.setBackgroundResource(2130837544);
      }
    case 2:
    }
    this.a.g = i;
    if ((this.a.M) && (!(this.a.N)) && (Show_Control.g(this.a) != 5) && (!(this.a.E)))
    {
      Show_Control.a("Test", "ACTION_MOVE" + i);
      this.a.h = this.a.Q[this.a.g];
      if ((this.a.h != null) && (!(this.a.h.equals(""))))
      {
        this.a.N = true;
        if (this.a.V[i] == 0)
          break label1476;
        this.a.aC = 6;
        new Thread(Show_Control.m(this.a)).start();
      }
    }
    while (true)
    {
      new Timer().schedule(new eq(this.a), this.a.L);
      return false;
      label1476: this.a.aC = 1;
      new Thread(Show_Control.m(this.a)).start();
    }
  }
}